package participle.test;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.hankcs.hanlp.seg.common.Term;
import com.zizo.file.util.FileUtil;

import participle.jar.Participle;

public class Word2File {
	public void participle() {
		List<String> clist = FileUtil.readFile2List("C:/Users/Apple/Desktop/WorkProject/participle/bbs_c_364.txt");
		for (String content : clist) {
			String s = content.replaceAll(
					"(http://|ftp://|https://|www){0,1}[^\u4e00-\u9fa5\\s]*?\\.(com|net|cn|me|tw|fr)[^\u4e00-\u9fa5\\s]*",
					"");
			List<Term> terms = Participle.getTermList(getFilterData(s));
			for (Term term : terms) {
				FileUtil.writeFile(term.word + "\t", "C:/Users/Apple/Desktop/WorkProject/Participle/bbs_c_364_word.txt",
						true);
			}
		}
	}

	/**
	 * @Title: getFilterData
	 * @Description: TODO 去掉停止词
	 * @param content
	 * @return
	 * @return String
	 * @author Alexis
	 */
	public final String getFilterData(String content) {
		String s = "�|÷|→|※|∧|∥|∏|∑|√|∩|∪|∫|∮|☆|★|⊥|∷|∵|∨|⊙|□|▪|◎|〓|↑|〖|〗|＆|Ā|Ō|°|♀|☊ |々|「|」|￼|￣|\\*|・|ˇ|°|￥|￡|≈|≌|√|∠|∈|\\||∞|Š|Ū|Ǔ|Ò|Ê|=|\\d{6,}|、|\\?{3,}||▲|～|…{2,}|·|●|[A-Za-z]{6,}|―{3,}|◆|■|℃|%|％|\\.|￣|∀|｀|＾|］|⌒|＠{2,}|＄|＃|§| {3,}|﹏|　{2,}";
		Pattern p_1 = Pattern.compile(s);
		Matcher m_1 = p_1.matcher(content);
		String res_1 = m_1.replaceAll("");
		return res_1;
	}

	public static void main(String[] args) {
		Word2File w = new Word2File();
		w.participle();
	}
}
